-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix overriding a Java method with varargs #2076
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
odersky
merged 2 commits into
scala:master
from
dotty-staging:fix/override-java-varargs
Mar 12, 2017
Merged
Fix overriding a Java method with varargs #2076
odersky
merged 2 commits into
scala:master
from
dotty-staging:fix/override-java-varargs
Mar 12, 2017
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, I forgot to add the testcase, I'll amend the commit. |
If A method like: override def foo(x: Object*) overrides a Java method, it needs to be rewritten as: def foo(x: Seq[Object]) override def foo(x: Array[Object]): Object = foo(Predef.wrapRefArray(x)) This should be handled by ElimRepeated but there were two bugs: - `addVarArgsBridge` was called at phase `thisTransformer.next`, this is too late to create the bridge since `T*` has already been rewritten as `Seq[T]` - The original method symbol needs to have the `override` flag dropped, since it doesn't override anything. Furthermore, RefChecks had to be moved after ElimRepeated, otherwise the testcase would fail the overriding checks.
c26d2fc
to
e5e691e
Compare
This was a mistake introduced in the previous commit, installAfter is only safe to use in `IdentityDenotTransformer` phases, otherwise it means that the phase denotation transformer is not run at all for this particular denotation, this caused Ycheck to fail.
odersky
approved these changes
Mar 12, 2017
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good. I think this is much better than burdening TypeComparer with the distinction of different implementations of varargs methods.
smarter
added a commit
to dotty-staging/dotty
that referenced
this pull request
Mar 12, 2017
This wasn't done before because dotty could not compile dottydoc, this got fixed by PRs scala#2070 and scala#2076.
smarter
added a commit
to dotty-staging/dotty
that referenced
this pull request
Mar 12, 2017
This wasn't done before because dotty could not compile dottydoc, this got fixed by PRs scala#2070 and scala#2076.
smarter
added a commit
to dotty-staging/dotty
that referenced
this pull request
Mar 13, 2017
This wasn't done before because dotty could not compile dottydoc, this got fixed by PRs scala#2070 and scala#2076.
smarter
added a commit
to dotty-staging/dotty
that referenced
this pull request
Mar 13, 2017
This wasn't done before because dotty could not compile dottydoc, this got fixed by PRs scala#2070 and scala#2076, and the previous commit fixed a miscompilation issue.
smarter
added a commit
to dotty-staging/dotty
that referenced
this pull request
Mar 14, 2017
This wasn't done before because dotty could not compile dottydoc, this got fixed by PRs scala#2070 and scala#2076, and the previous commit fixed a miscompilation issue.
smarter
added a commit
to dotty-staging/dotty
that referenced
this pull request
Mar 15, 2017
This wasn't done before because dotty could not compile dottydoc, this got fixed by PRs scala#2070 and scala#2076, and the previous commit fixed a miscompilation issue.
smarter
added a commit
to dotty-staging/dotty
that referenced
this pull request
Mar 15, 2017
This wasn't done before because dotty could not compile dottydoc, this got fixed by PRs scala#2070 and scala#2076, and the previous commit fixed a miscompilation issue.
smarter
added a commit
to dotty-staging/dotty
that referenced
this pull request
Mar 15, 2017
This wasn't done before because dotty could not compile dottydoc, this got fixed by PRs scala#2070 and scala#2076, and the previous commit fixed a miscompilation issue.
smarter
added a commit
to dotty-staging/dotty
that referenced
this pull request
Mar 16, 2017
This wasn't done before because dotty could not compile dottydoc, this got fixed by PRs scala#2070 and scala#2076, and the previous commit fixed a miscompilation issue.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
If A method like:
overrides a Java method, it needs to be rewritten as:
This should be handled by ElimRepeated but there were two bugs:
addVarArgsBridge
was called at phasethisTransformer.next
, this istoo late to create the bridge since
T*
has already been rewritten asSeq[T]
override
flag dropped,since it doesn't override anything.
Furthermore, RefChecks had to be moved after ElimRepeated, otherwise
the testcase would fail the overriding checks.
@odersky I'm not sure if moving RefChecks is the best solution here. Alternatively we could teach TypeComparer about repeated params when we compare MethodTypes in a phase before ElimRepeated.